/*
 * MineralSolution.cpp
 *
 *  Created on: 24 May 2011
 *      Author: allan
 */

#include "MineralSolution.h"

// C++ includes
#include <numeric>

MineralSolution::MineralSolution()
{}

MineralSolution::MineralSolution(const StringVector& species) :
species(species)
{}

const StringVector& MineralSolution::GetSpecies() const
{
	return species;
}

const DoubleVector MineralSolution::ActivityCoefficients(double T, double P, const DoubleVector& n) const
{
	DoubleVector lambda(species.size(), 1.0);
	
	return lambda;
}

const DoubleVector MineralSolution::Activities(double T, double P, const DoubleVector& n) const
{
	DoubleVector a(ActivityCoefficients(T, P, n));
	
	const double nT = std::accumulate(n.begin(), n.end(), 0.0);
	
	for(unsigned i = 0; i < species.size(); ++i)
		a[i] *= n[i]/nT;
	
	return a;
}
